package com.example.shopping.shipping.mapper;

import com.example.shopping.shipping.entity.Shipping;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface ShippingMapper {
    //查询
    @Select("select * from shipping where userId=#{userid}")
    List<Shipping> getshipping(@Param("userid")int userid);
    @Delete("delete from shipping where id=#{id}")
    int delshipping(@Param("id") int id);
    //增加
    @Insert("INSERT INTO shipping(userId,name,mobile,Province,city,district,addr,dfault) VALUES(#{userId},#{name},#{mobile},#{Province},#{city},#{district},#{addr},#{dfault})")
    @Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
    int addShipping(Shipping shipping);
    //修改
    @Update("update shipping set name=#{name},mobile=#{mobile},Province=#{Province},city=#{city},district=#{district},addr=#{addr},dfault=#{dfault} where id=#{id}")
    int upShipping(Shipping shipping);

    //修改默认
    @Update("update shipping set dfault=0 where id!=#{id}")
    int UpdDfault(@Param("id")int id);
}
